#region Using directives

using System;

#endregion

namespace Hanoi.Logic.Profiles
{
    public class RandomProfile : ProfileBase, IGame
    {
        private int _start, _end, _moves, _size, _columns;
        private bool _timeControled;
        private TimeSpan _timeAmount;

        public int _secondsByMove;

        public RandomProfile()
        {
            InitializeRandom();
        }

        private void InitializeRandom()
        {
            _secondsByMove = 3 + base.GetRandomNumber(5);
            _start = base.GetRandomNumber(3);
            _end = base.GetRandomNumber(3, _start);
            _size = base.GetRandomNumber(8) + 1;
            _moves = base.CalculateMoves(_size) * (base.GetRandomNumber(4) + 1);
            _timeControled = base.GetRandomNumber(2) == 1 ? true : false;
            if (_timeControled)
                _timeAmount = new TimeSpan(0, 0, _secondsByMove * _moves);
            _columns = 3 + base.GetRandomNumber(2);

            Hanoi.Logic.Profiles.LastProfile.Set(this);
        }

        #region IGame Members

        public int Start
        {
            get
            {
                InitializeRandom();
                return _start;
            }
        }

        public int End
        {
            get { return _end; }
        }

        public int Moves
        {
            get { return _moves; }
        }

        public int Size
        {
            get { return _size; }
        }

        public bool TimeControled
        {
            get { return _timeControled; }
        }

        public TimeSpan TimeAmount
        {
            get { return _timeAmount; }
        }

        public int Columns
        {
            get { return _columns; }
        }

        #endregion
    }
}
